package com.jinzhi.jzweb.pojo.statistics;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.DoubleSummaryStatistics;

/*
 *  @author : JingChangTian
 *  @date   : 2024/4/16 10:16
 *  @description :
 *
 */
@Data
public class ScoreIntervalVo{


    public ScoreIntervalVo() {
    }


    public ScoreIntervalVo(String field, DoubleSummaryStatistics summary) {
        this.field = field;
        this.summary = summary;
        if(String.valueOf(summary.getAverage()).equals("NaN")){
            this.setAverageScore(0.0);
        }else{
            this.setAverageScore(new BigDecimal(summary.getAverage()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
        }
        if(summary.getAverage()==0.0){
            this.setHighestScore(0.0);
            this.setLowestScore(0.0);
            this.setScoreRange(0.0);
        }else{
            this.setHighestScore(new BigDecimal(summary.getMax()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
            this.setLowestScore(new BigDecimal(summary.getMin()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
            double s = this.getHighestScore() - this.getLowestScore();
            this.setScoreRange(new BigDecimal(s).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
        }

    }


    @ApiModelProperty(value = "最高分")
    private Double highestScore;

    @ApiModelProperty(value = "最低分")
    private Double lowestScore;

    @ApiModelProperty(value = "平均分")
    private Double averageScore;

    @ApiModelProperty(value = "分差")
    private Double scoreRange;

    @ApiModelProperty(value = "赛场")
    private String field;

    @ApiModelProperty(value = "分值信息")
    private DoubleSummaryStatistics summary;


}
